<?php
/*
 * Camelot PHP Tools
 *
 * @version 2.0
 * @author Bendsoft
 * @package PHP Tools
 * @subpackage Camelot
 * @license FreeBSD License (www.bendsoft.com/licensing/)
 *
 */

class CamelotDump extends Db {

    public $camelot_dump_id = 0;
    public $camelot_dump_packet = 0;
    public $camelot_dump_ip = 0;
    public $camelot_dump_date = 0;
    public $camelot_dump_packet_md5 = 0;

    public function open($id) {
        if (is_numeric($id)) {
            $sql = "SELECT * FROM camelot_dump WHERE camelot_dump_id = '$id'";
            $res = parent::DB_SELECT($sql);
            if (mysql_num_rows($res) <> 1) {
                return 0;
            }
        } else {
            $sql = "SELECT * FROM camelot_dump " . $id;
            $res = parent::DB_SELECT($sql);
            if (mysql_num_rows($res) <= 0) {
                return 0;
            }
        }


        $data = array();
        while ($row = mysql_fetch_array($res)) {
            $this->camelot_dump_id = $row['camelot_dump_id'];
            $this->camelot_dump_packet = $row['camelot_dump_packet'];
            $this->camelot_dump_ip = $row['camelot_dump_ip'];
            $this->camelot_dump_date = $row['camelot_dump_date'];
            $this->camelot_dump_packet_md5 = $row['camelot_dump_packet_md5'];
            $data[] = (array) $this;
        }
        return $data;
    }

    public function save($id) {
        if ($id > 0) {
            $sql = "UPDATE camelot_dump SET camelot_dump_packet = '$this->camelot_dump_packet', camelot_dump_ip = '$this->camelot_dump_ip', camelot_dump_date = '$this->camelot_dump_date', camelot_dump_packet_md5 = '$this->camelot_dump_packet_md5' WHERE camelot_dump_id = '$id'";
            $res = parent::DB_UPDATE($sql);
        } else {
            $sql = "INSERT INTO camelot_dump (camelot_dump_packet, camelot_dump_ip, camelot_dump_date, camelot_dump_packet_md5) VALUES ('$this->camelot_dump_packet', '$this->camelot_dump_ip', '$this->camelot_dump_date', '$this->camelot_dump_packet_md5')";
            $res = parent::DB_INSERT($sql);
        }

        if ($res != 0 || !$res)
            $res = mysql_insert_id();# Instead of RETURNING
        return $res;
    }

    public function update($indata) {
        $sql = "UPDATE camelot_dump SET $indata";
        $res = parent::DB_UPDATE($sql);
        if ($res != 0 || !$res)
            $res = mysql_insert_id();# Instead of RETURNING
        return $res;
    }

    public function delete($id) {
        $sql = "DELETE FROM camelot_dump WHERE camelot_dump_id = '$id'";
        $res = parent::DB_DELETE($sql);
        return $res;
    }

    
    public function setCamelotDumpId($camelot_dump_id) { $this->camelot_dump_id = addslashes($camelot_dump_id); }
    public function getCamelotDumpId() { return stripslashes($this->camelot_dump_id); }

    public function setCamelotDumpPacket($camelot_dump_packet) { $this->camelot_dump_packet = addslashes($camelot_dump_packet); }
    public function getCamelotDumpPacket() { return stripslashes($this->camelot_dump_packet); }

    public function setCamelotDumpIp($camelot_dump_ip) { $this->camelot_dump_ip = addslashes($camelot_dump_ip); }
    public function getCamelotDumpIp() { return stripslashes($this->camelot_dump_ip); }

    public function setCamelotDumpDate($camelot_dump_date) { $this->camelot_dump_date = addslashes($camelot_dump_date); }
    public function getCamelotDumpDate() { return stripslashes($this->camelot_dump_date); }

    public function setCamelotDumpPacketMd5($camelot_dump_packet_md5) { $this->camelot_dump_packet_md5 = addslashes($camelot_dump_packet_md5); }
    public function getCamelotDumpPacketMd5() { return stripslashes($this->camelot_dump_packet_md5); }

}
?>
